package com.ruipengkj.commons.util.DBDump;

import com.ruidom.Com.Transform.DBDump.XMLDataLoader;
import com.ruidom.LinJiaYou.Db.DBHelper;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserFactory;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.sql.Connection;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 12-10-23
 * Time: 上午2:33
 * To change this template use File | Settings | File Templates.
 */
public class LoadTest {
    public static void main(String[] args)
    {
        try {
            XmlPullParser xpp = null;
            XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
            factory.setNamespaceAware(true);
            xpp = factory.newPullParser();
            BufferedReader breader = new BufferedReader(new InputStreamReader(new FileInputStream("test.xml")), 1024 * 2);
            xpp.setInput(breader);
            Connection conn = DBHelper.GetInstance().getConnection();
            long start = System.currentTimeMillis();
            new XMLDataLoader(null).load(conn, xpp);
            System.out.println("数据导入耗时：" + (System.currentTimeMillis() - start));
            conn.close();
            breader.close();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}
